home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / cannons / code.lua next >
Text File  |  2005-07-16  |  5KB  |  182 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky06.ogg")
  8.     local pokus = getRestartCount()
  9.  
  10.  
  11.     -- -------------------------------------------------------------
  12.     local function prog_init_room()
  13.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  14.  
  15.         if random(100) < 50 then
  16.             room.uvod = 0
  17.         else
  18.             room.uvod = 1
  19.         end
  20.         room.tuseni = 0
  21.         room.jo = 0
  22.         room.pocitadlo = random(500) + 500
  23.  
  24.         return function()
  25.             if isReady(small) and isReady(big) and no_dialog() then
  26.                 switch(room.uvod){
  27.                     [0] = function()
  28.                         addv(20 + random(30), "del-v-dve")
  29.                         addm(random(5), "del-m-voda")
  30.                         room.uvod = 2
  31.                     end,
  32.                     [1] = function()
  33.                         addm(20 + random(30), "del-m-ci")
  34.                         addv(random(5), "del-v-splet")
  35.                         room.uvod = 2
  36.                     end,
  37.                 }
  38.                 if room.pocitadlo < 1 and room.tuseni == 0 then
  39.                     addv(random(5), "del-v-mec")
  40.                     addm(random(5), "del-m-tus")
  41.                     room.tuseni = 1
  42.                 end
  43.                 room.pocitadlo = room.pocitadlo - 1
  44.             elseif isReady(small) and big:isOut() and room.jo == 0 and (small.X < 2 or small.X > 25) then
  45.                 small:setBusy(true)
  46.                 switch(random(2)){
  47.                     [0] = function()
  48.                         addm(0, "del-m-jedn0")
  49.                     end,
  50.                     [1] = function()
  51.                         addm(0, "del-m-jedn1")
  52.                     end,
  53.                 }
  54.                 addm(random(5), "del-m-jedn2")
  55.                 room.jo = 1
  56.                 planBusy(small, false)
  57.             end
  58.         end
  59.     end
  60.  
  61.     -- -------------------------------------------------------------
  62.     local function prog_init_delo1()
  63.         return function()
  64.             switch(math.mod(game_getCycles() + 1, 4)){
  65.                 [0] = function()
  66.                     delo1.afaze = 2
  67.                 end,
  68.                 [2] = function()
  69.                     delo1.afaze = 2
  70.                 end,
  71.                 [1] = function()
  72.                     delo1.afaze = 0
  73.                 end,
  74.                 [3] = function()
  75.                     delo1.afaze = 1
  76.                 end,
  77.             }
  78.             delo1:updateAnim()
  79.         end
  80.     end
  81.  
  82.     -- -------------------------------------------------------------
  83.     local function prog_init_delo3()
  84.         return function()
  85.             switch(math.mod(game_getCycles(), 4)){
  86.                 [0] = function()
  87.                     delo3.afaze = 2
  88.                 end,
  89.                 [2] = function()
  90.                     delo3.afaze = 2
  91.                 end,
  92.                 [1] = function()
  93.                     delo3.afaze = 0
  94.                 end,
  95.                 [3] = function()
  96.                     delo3.afaze = 1
  97.                 end,
  98.             }
  99.             delo3:updateAnim()
  100.         end
  101.     end
  102.  
  103.     -- -------------------------------------------------------------
  104.     local function prog_init_delo2()
  105.         return function()
  106.             switch(math.mod(game_getCycles() + 3, 4)){
  107.                 [0] = function()
  108.                     delo2.afaze = 2
  109.                 end,
  110.                 [2] = function()
  111.                     delo2.afaze = 2
  112.                 end,
  113.                 [1] = function()
  114.                     delo2.afaze = 0
  115.                 end,
  116.                 [3] = function()
  117.                     delo2.afaze = 1
  118.                 end,
  119.             }
  120.             delo2:updateAnim()
  121.         end
  122.     end
  123.  
  124.     -- -------------------------------------------------------------
  125.     local function prog_init_delo4()
  126.         return function()
  127.             switch(math.mod(game_getCycles() + 1, 4)){
  128.                 [0] = function()
  129.                     delo4.afaze = 2
  130.                 end,
  131.                 [2] = function()
  132.                     delo4.afaze = 2
  133.                 end,
  134.                 [1] = function()
  135.                     delo4.afaze = 0
  136.                 end,
  137.                 [3] = function()
  138.                     delo4.afaze = 1
  139.                 end,
  140.             }
  141.             delo4:updateAnim()
  142.         end
  143.     end
  144.  
  145.     -- --------------------
  146.     local update_table = {}
  147.     local subinit
  148.     subinit = prog_init_room()
  149.     if subinit then
  150.         table.insert(update_table, subinit)
  151.     end
  152.     subinit = prog_init_delo1()
  153.     if subinit then
  154.         table.insert(update_table, subinit)
  155.     end
  156.     subinit = prog_init_delo3()
  157.     if subinit then
  158.         table.insert(update_table, subinit)
  159.     end
  160.     subinit = prog_init_delo2()
  161.     if subinit then
  162.         table.insert(update_table, subinit)
  163.     end
  164.     subinit = prog_init_delo4()
  165.     if subinit then
  166.         table.insert(update_table, subinit)
  167.     end
  168.     return update_table
  169. end
  170. local update_table = prog_init()
  171.  
  172.  
  173. -- -----------------------------------------------------------------
  174. -- Update
  175. -- -----------------------------------------------------------------
  176. function prog_update()
  177.     for key, subupdate in pairs(update_table) do
  178.         subupdate()
  179.     end
  180. end
  181.  
  182.